

class T {
    public void func() {
        synchronized (this) {
            System.out.println("我被加锁了");
        }
    }
}
public class Day2 {

    public static void main(String[] args) {
        T tt = new T();
        Thread t = new Thread(()->{
            synchronized (tt) {
                tt.func();
            }
        });
        t.start();
    }

}
